package collection;

import java.util.ArrayList;
import java.util.List;

public class ListDemo3 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++){
            list.add(i);
        }
        System.out.println(list);
        //获取[2-7]
        List<Integer> subList=list.subList(2,8);
        System.out.println(subList);

        //[,20,30,40,50,60,70]
       for (int i = 0; i < subList.size(); i++){
           int s=subList.get(i);
           subList.set(i,s*10);

       }
        System.out.println(subList);
        /**
         * 对子集的修改，也会影响原集合
         */
       System.out.println(list);
//    删除list集合中的1-8
      list.subList(1,9).clear();
      System.out.println(list);
    }
}
